<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="author" content="wangbo">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <table border="1" align="center">
        <tr>
            <td>账户:</td>
            <td>
                <input type="text" id="Username" onblur="op_1()" />
            </td>
            <td id="td_1"></td>
        </tr>
        <tr>
            <td>密码：</td>
            <td>
                <input type="password" id="password_1" onblur="op_2()" />
            </td>
            <td id="td_2">
            </td>
        </tr>
        <tr>
            <td>确认密码:</td>
            <td>
                <input type="password" id="password_2" onblur="op_3()" />
            </td>
            <td id="td_3">
            </td>
        </tr>
        <tr>
            <td>家庭住址：</td>
            <td>
                <select>
                    <option>--请选择省份--</option>
                    <option>河南</option>
                    <option>河北</option>
                    <option>河东</option>
                    <option>河西</option>
                </select>
                <select>
                    <option>--请选择城市--</option>
                    <option>天南市</option>
                    <option>天北市</option>
                    <option>天东市</option>
                    <option>天西市</option>
                </select>
            </td>
            <td id="td_4"></td>
        </tr>
        <tr>
            <td colspan="3" align="center">
                <input type="button" id="submit" value="提交" />
            </td>
        </tr>
    </table>
    <script type="text/javascript">
        function op_1() {
            var op = /^[a-zA-Z]{6,}$/
            var Username = document.getElementById("Username").value
            if (op.test(Username)) {
                document.getElementById("td_1").innerHTML = "用户名格式正确"
                return true
            } else {
                document.getElementById("td_1").innerHTML = "错误,长度最少6位,字母组成"
                return false
            }
        }
        function op_2() {
            var op = /^\d{5,7}$/
            var password_1 = document.getElementById("password_1").value
            if (op.test(password_1)) {
                document.getElementById("td_2").innerHTML = "密码输入正确"
                return true
            } else {
                document.getElementById("td_2").innerHTML = "错误,长度5-7,数字组成"
                return false
            }
        }
        document.getElementById("submit").onclick = function () {
            if (op_1()&&op_2()) {
                alert("登陆成功")
            } else {
                alert("校验失败,不需登录")
            }
        }
    </script>

</body>

</html>